<template>
  <div class="gl_heightFull">
    <div class="demo-input-suffix gl_searchBox">
      <el-row :gutter="20">
        <el-col :md="4" :lg="4">
          <p>账号状态</p>
          <el-select v-model="IsEnabled" size="mini" @change="getList()">
            <el-option label="全部" value="" />
            <el-option label="启用" :value="true" />
            <el-option label="停用" :value="false" />
          </el-select>
        </el-col>
        <el-col :md="4" :lg="4">
          <p>姓名/手机号</p>
          <el-input v-model="Api_GET_ClubBranchBranchEmployeesQO.Filter" placeholder="请输入姓名/手机号" size="mini" clearable @change="getList()" />
        </el-col>
        <el-col :md="4" :lg="4">
          <el-button type="primary" style="margin-top:25px" size="mini" @click="getList()">筛选</el-button>
          <el-button type="warning" size="mini" @click="reset()">{{ $t('button.Reset') }}</el-button>
        </el-col>
      </el-row>
    </div>
    <div style="margin-top:15px">
      <el-table v-loading="tableLoading" class="gl_table_noBorder" size="mini" :data="tableData">
        <el-table-column label="姓名" align="center" width="150">
          <template slot-scope="{row}">
            <el-popover placement="bottom" width="200" trigger="hover" :content="row.name">
              <div slot="reference" class="nav_name">
                {{ row.name }}
              </div>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column label="手机号码" prop="phoneNumber" width="150" />
        <el-table-column label="角色名称" align="center" prop="roleName" />
        <el-table-column label="状态" align="center">
          <template slot-scope="{row}">
            <div v-if="row.isEnabled === true"><i class="success_circle" />已启用</div>
            <div v-else><i class="error_circle" />已停用</div>
          </template>
        </el-table-column>
        <el-table-column label="描述" prop="description" />
      </el-table>
    </div>
    <!-- 分页 -->
    <el-row class="gl_pt_15" style="text-align: right;">
      <el-pagination
        :current-page="Api_GET_ClubBranchBranchEmployeesQO.Page"
        :page-size="Api_GET_ClubBranchBranchEmployeesQO.MaxResultCount"
        :total="totalPage"
        layout="total,sizes,prev,pager,next,jumper"
        :page-sizes="[10, 20, 30, 40]"
        @size-change="sizeChange"
        @current-change="pageIndexChange"
      />
    </el-row>
  </div>
</template>

<script>
import { api_GET_ClubBranchBranchEmployees } from '@/extend/api/hallswaggerApi/app.js';
import { Api_GET_ClubBranchBranchEmployeesQO } from '@/lib/form/hall/swaggerForm';
export default {
  data() {
    return {
      Api_GET_ClubBranchBranchEmployeesQO: new Api_GET_ClubBranchBranchEmployeesQO(), // 员工列表
      tableData: [],
      tableLoading: false,
      IsEnabled: '',
      totalPage: 0,
      currentPage: 1
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 获取员工列表
    getList(page) {
      this.tableLoading = true;
      this.Api_GET_ClubBranchBranchEmployeesQO.IsEnabled = this.IsEnabled;
      this.Api_GET_ClubBranchBranchEmployeesQO.BranchId = this.$parent.$parent.$parent.branchid;
      this.Api_GET_ClubBranchBranchEmployeesQO.Page = page || 1;
      this.Api_GET_ClubBranchBranchEmployeesQO.CanTeach = '';
      this.Api_GET_ClubBranchBranchEmployeesQO.SkipCount = (this.Api_GET_ClubBranchBranchEmployeesQO.Page - 1) * this.Api_GET_ClubBranchBranchEmployeesQO.MaxResultCount;
      api_GET_ClubBranchBranchEmployees(this.Api_GET_ClubBranchBranchEmployeesQO).then(res => {
        this.tableLoading = false;
        this.tableData = res.items;
        this.totalPage = res.totalCount;
        this.$parent.$parent.$parent.tabList[0].label = '员工(' + res.totalCount + ')';
      }, error => {
        this.tableLoading = false;
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
      });
    },
    // 重置按钮
    reset () {
      this.Api_GET_ClubBranchBranchEmployeesQO = new Api_GET_ClubBranchBranchEmployeesQO();
      this.IsEnabled = '';
      this.getList();
    },
    // 分页按钮
    sizeChange(MaxResultCount) {
      this.Api_GET_ClubBranchBranchEmployeesQO.MaxResultCount = MaxResultCount;
      this.getList();
    },
    pageIndexChange(currentPage) {
      this.getList(currentPage);
    }
  }
};
</script>

<style lang="scss" scoped>
.success_circle {
  display: inline-block;
  margin-right: 8px;
  width: 6px;
  height: 6px;
  background: #14CE67;
  border-radius: 50%;
}
.error_circle {
  display: inline-block;
  margin-right: 8px;
  width: 6px;
  height: 6px;
  background: #FF3434;
  border-radius: 50%;
}
.nav_name {
  display: inline-block;
  width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 9px;
}
</style>
